package com.galeno.udfs;

import com.galeno.pojo.LogBean;
import org.apache.flink.configuration.Configuration;
import org.apache.flink.streaming.api.functions.KeyedProcessFunction;
import org.apache.flink.util.Collector;
import org.apache.hadoop.hbase.client.Connection;

import java.util.Map;

/**
 * @author galeno
 * @Title:
 * @Description:
 * @date 2021/11/119:31
 */
@Deprecated
public class Rules匹配函数 extends KeyedProcessFunction<String, LogBean,String> {
    private Connection  hbaseConn;
    private java.sql.Connection clickHouseConn;
    @Override@Deprecated
    public void open(Configuration parameters) throws Exception {
        super.open(parameters);
        //TODO 使用ListState保存用户最近2小时的数据
        //创建Hbase链接


        //创建clickhouse链接

    }
    @Deprecated
    @Override
    public void processElement(LogBean bean, Context ctx, Collector<String> out) throws Exception {
        String eventId = bean.getEventId();
        String deviceId = bean.getDeviceId();
        Map<String, String> properties = bean.getProperties();


        //1匹配eventID
        if ("E".equals(eventId)&&"v1".equals(properties.get("p2"))){
            //2匹配用户画像


            //3匹配历史行为数据

        }else {

        }



    }

    @Override@Deprecated
    public void close() throws Exception {
        //关闭链接
        clickHouseConn.close();
        hbaseConn.close();

    }
}
